<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>百度地图</title>
</head>
<body>
<div id="container"></div>
<script type="text/javascript" src="{{asset('/default/js/jquery.js')}}"></script>
<script type="text/javascript" src="{{getRequestType()}}://api.map.baidu.com/api?v=2.0&ak={{ Site::get('mapKey') }}" ></script>
<script type="text/javascript" src="{{asset('/default/js/jquery/jquery.cxscroll.min.js')}}"></script>
<script type="text/javascript" src="{{getRequestType()}}://api.map.baidu.com/library/SearchInfoWindow/1.5/src/SearchInfoWindow_min.js"></script>
<link rel="stylesheet" href="{{getRequestType()}}://api.map.baidu.com/library/SearchInfoWindow/1.5/src/SearchInfoWindow_min.css" />

<script type="text/javascript">
    //调整高宽
    w = $(window).width();
    h = $(window).height();

    $("#container").css("width",w+"px");
    $("#container").css("height",h+"px");
    $("#container").css("overflow-x","hidden");
    $("#container").css("overflow-y","hidden");

    if(w > 600 || h > 350){
        // 百度地图API功能
        var map = new BMap.Map('container');
        var poi = new BMap.Point('{{ $company->longitude }}','{{ $company->latitude }}');
        map.centerAndZoom(poi, 16);
        map.enableScrollWheelZoom();

        var content = '<div style="margin:0;line-height:20px;padding:2px;min-height:70px;overflow: hidden;">' +
                '<img src="{{ url("$company->logo") }}" alt="" style="float:right;zoom:1;width:65px;height:65px;margin-left:3px;"/>' +
                "<div style='line-height:20px;min-height:20px;'>地址：{{ $company->address or '' }}</div>" +
                '</div>';

        //创建检索信息窗口对象
        var searchInfoWindow = null;
        searchInfoWindow = new BMapLib.SearchInfoWindow(map, content, {
            title  : "{{ $company->company_name or '' }}",      //标题
            width  : 290,             //宽度
            height : 78,              //高度
            panel  : "panel",         //检索结果面板
            enableAutoPan : true,     //自动平移
            searchTypes   :[
                BMAPLIB_TAB_SEARCH,   //周边检索
                BMAPLIB_TAB_TO_HERE,  //到这里去
                BMAPLIB_TAB_FROM_HERE //从这里出发
            ]
        });
        var marker = new BMap.Marker(poi); //创建marker对象
        marker.enableDragging(); //marker可拖拽
        searchInfoWindow.open(marker);
        marker.addEventListener("click", function(e){
            searchInfoWindow.open(marker);
        });
        map.addOverlay(marker); //在地图中添加marker

        @if(empty($company->longitude) && empty($company->latitude))
            var marker='';
            var xyPoint=new BMap.Point('{{ $company->longitude or '' }}','{{ $company->latitude or '' }}');
            map.centerAndZoom(xyPoint, 15);
            map.addControl(new BMap.NavigationControl());
            map.addControl(new BMap.MapTypeControl());

            var myIcon = new BMap.Icon("{{ asset('default/images/index/noBmapbig.png') }}", new BMap.Size(168,50));  //定义自己的标注
            marker = new BMap.Marker(xyPoint,{icon:myIcon});  // 创建标注
            map.addOverlay(marker);             // 将标注添加到地图中
        @endif

   }else{
        //百度地图
        var map = new BMap.Map("container");
        var marker='';
        var xyPoint=new BMap.Point('{{ $company->longitude or '' }}','{{ $company->latitude or '' }}');
        map.centerAndZoom(xyPoint, 15);
        map.addControl(new BMap.NavigationControl());
        map.addControl(new BMap.MapTypeControl());

        @if(empty($company->longitude) && empty($company->latitude))
            var myIcon = new BMap.Icon("{{ asset('default/images/index/noBmap.png') }}", new BMap.Size(168,30));  //定义自己的标注
            marker = new BMap.Marker(xyPoint,{icon:myIcon});  // 创建标注
            map.addOverlay(marker);             // 将标注添加到地图中
        @else
            marker = new BMap.Marker(xyPoint);  // 创建标注
            map.addOverlay(marker);             // 将标注添加到地图中
        @endif

        //map.addControl(new BMap.enableScrollWheelZoom());
        map.enableScrollWheelZoom();
        map.disableDoubleClickZoom();
    }


</script>
</body>
</html>
